import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import './assets/styles/index.scss'
import { handleResizeObserverLoopError } from '@/utils/resize-observer'

// ECharts 相关导入
import VChart from 'vue-echarts'
import * as echarts from 'echarts'

// 处理 ResizeObserver 错误
handleResizeObserverLoopError()

const app = createApp(App)
const pinia = createPinia()

// 注册Element Plus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 全局注册 vue-echarts 组件
app.component('v-chart', VChart)

app.use(pinia)
   .use(router)
   .use(ElementPlus, {
     size: 'default',
     zIndex: 3000
   })
   .mount('#app') 